package com.neusoft.ysu.his.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.ysu.his.entity.CommonResult;
import com.neusoft.ysu.his.entity.Patient;
import com.neusoft.ysu.his.mapper.PatientMapper;
import com.neusoft.ysu.his.service.IPatientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2023-08-25
 */
@Service
public class PatientServiceImpl implements IPatientService {
    @Autowired
    PatientMapper patientMapper;
    @Override
    public CommonResult add(Patient patient) {
        int i=patientMapper.insert(patient);
        return new CommonResult<>(patient.getId());
    }

    @Override
    public CommonResult deleteById(int id) {
        return null;
    }

    @Override
    public CommonResult update(Patient patient) {

        return new CommonResult<>(patientMapper.update(patient,null));
    }

    @Override
    public CommonResult selectAll() {
        QueryWrapper<Patient> queryWrapper=new QueryWrapper<>();
        queryWrapper.gt("delmark",-1);
        queryWrapper.lt("delmark",4);
        System.out.println("all:"+patientMapper.selectList(queryWrapper));
        return new CommonResult<>(patientMapper.selectList(queryWrapper));
    }

    @Override
    public CommonResult selectById(int id) {
        return null;
    }

    @Override
    public CommonResult calculateUseNum(Patient patient) {
        String noon=patient.getNoon();
        int weekday=patient.getWeekday();
        int doc_id=patient.getDocId();
        System.out.println("send:"+noon+" "+weekday+" "+doc_id);
        return null;
    }

    @Override
    public CommonResult reDelById(int id, int delmark) {
        System.out.println("1:"+delmark+" "+id);
        return new CommonResult<>(patientMapper.reDelById(delmark,id));
    }

    @Override
    public CommonResult findPaid() {

        System.out.println("all:"+patientMapper.selectList(null));
        List<Patient> patients=patientMapper.findPaid();
        return new CommonResult<>(patients);
    }


}
